﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using System.Xml.Serialization;
using System.IO; 

namespace EvePoint.Library.HtmlControls
{
    public class SPViewport: Viewport
    {

        #region Constants

        public static readonly string PROPERTYBAGKEY = "EvePoint_SPViewport";

        #endregion 

        public SPViewport()
        {
            SPWeb currentWeb=SPContext.Current.Web;

            if (currentWeb != null)
            {
                string serializedSPViewport = currentWeb.Properties[PROPERTYBAGKEY];

                if (!string.IsNullOrEmpty(serializedSPViewport))
                {



                    XmlSerializer serializer = new XmlSerializer(typeof(ViewportProperties));

                    using (StringReader sReader = new StringReader(serializedSPViewport))
                    {
                        ViewportProperties viewport = (ViewportProperties)serializer.Deserialize(sReader);

                        UseDeviceHeightAndWidth = viewport.UseDeviceHeightAndWidth;
                        UserScalable = viewport.UserScalable;
                        InitialScale = viewport.InitialScale;
                        Width = viewport.Width;
                        Height = viewport.Height;
                        MaximumScale = viewport.MaximumScale;
                        MinimumScale = viewport.MinimumScale;

                    }
                }
            }
        }

        
    }


}
